#include <iostream>
#include <string>
#include <memory>
#include "ThreadPool.hpp"
#include "Log.hpp"
using namespace std;
using namespace ThreadModule;

int main()
{
    srand(time(nullptr)^getpid()^pthread_self());
    //DisableFile();
    EnableFile();
    // LogMessage(__FILE__,__LINE__,DEBUG,"hello world %s","debug");
    // LogMessage(__FILE__,__LINE__,INFO,"hello world %s","info");
    // LogMessage(__FILE__,__LINE__,WARNING,"hello world %s,%d","warning",100);
    // LogMessage(__FILE__,__LINE__,ERROR,"hello world %s","error");
    // LOG(INFO,"hello world %s","debug");
    std::unique_ptr<ThreadPool<Task>> tq=std::make_unique<ThreadPool<Task>>(10);
    tq->InitThreadPool();
    tq->Start();
    sleep(3);
    int taskNum=10;
    while(taskNum--)
    {
        int a=rand()%10+1;
        usleep(1234);
        int b=rand()%10+1;
        Task t(a,b);
        tq->Enqueue(t);
        LOG(DEBUG,"enqueue a task done");
        sleep(1);
    }
    LOG(DEBUG,"All task enqueue done");

    //tq->Enqueue(1);
    tq->Stop();
    tq->Wait();
    return 0;
}